<?php
allowCors();
if (!methodsRequired(['get','post'])) return;
if (!checkAdmin($msg)) return;

$user = new User();
//必选参数
if(isset($_REQUEST['user_id'])) {

//可选参数
    $newData=[];
    $user->setUserId($_REQUEST['user_id']);
    foreach (array_merge(User::$members_mapping, User::$required) as $item) {
        if (isset($_REQUEST[$item]) && $item != 'user_id') {
            $newData[$item]=$_REQUEST[$item];
        }
    }
    error_log($user);
    if (!$db->edit($user,$newData)) {
        $msg->setCode(3);
    }
}else{
    $msg->setCode(3);
}
echo $msg;